home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / SNDLIST- / SHOWINIT.C < prev    next >
Text File  |  1988-11-10  |  2KB  |  87 lines

  1. /*
  2.     Simple INIT notification routine in LightSpeedC 2.15
  3. */
  4.  
  5. #include <QuickDraw.h>
  6.  
  7. #define CKSM(i)                \
  8.     asm {                    \
  9.         ROL #1,i            \
  10.         EOR #0x1021,i        \
  11.     }
  12.  
  13. typedef struct QuickDraw {        /* QuickDraw globals */
  14.     char private[76];
  15.     long randSeed;
  16.     BitMap screenBits;
  17.     Cursor arrow;
  18.     Pattern dkGray;
  19.     Pattern ltGray;
  20.     Pattern gray;
  21.     Pattern black;
  22.     Pattern white;
  23.     GrafPtr thePort;
  24. } QuickDraw;
  25.  
  26. extern short myH : 0x92C;        /* CurApName + 28 */
  27. extern short myCheck: 0x92E;    /* CurApName + 30 */
  28. extern long oldSig: 0xA78;        /* ApplScratch */
  29. extern short oldH: 0xA7E;        /* ApplScratch + 6 */
  30.  
  31. void ShowINIT(iconID)
  32. register short iconID;            /* ICN# resource ID */
  33. {
  34.     register Handle h;
  35.     register short i;
  36.     Rect srcRect, destRect;
  37.     BitMap myBitMap;
  38.     GrafPort myPort;
  39.     QuickDraw qdGlobals;
  40.     Ptr localA5;
  41.  
  42.     asm {
  43.         MOVE.L A5,-(SP)
  44.         LEA.L localA5,A5
  45.     }
  46.     if (!(h = GetResource('ICN#', iconID)))
  47.         goto out;    /* Error */
  48.     InitGraf(&qdGlobals.thePort);
  49.     OpenPort(&myPort);
  50.  
  51.     i = myH;
  52.     CKSM(i);
  53.     if (i == myCheck)
  54.         i = myH;
  55.     else
  56.         if (oldSig == 'Paul')
  57.             i = oldH;
  58.         else
  59.             i = 8;
  60.     destRect.bottom = myPort.portRect.bottom - 8;
  61.     destRect.left = myPort.portRect.left + i;
  62.     destRect.top = destRect.bottom - 32;
  63.     destRect.right = destRect.left + 32;
  64.     i += 40;
  65.     myH = i;
  66.     CKSM(i);
  67.     myCheck = i;
  68.  
  69.     HLock(h);
  70.     srcRect.top = srcRect.left = 0;
  71.     srcRect.bottom = srcRect.right = 32;
  72.     myBitMap.rowBytes = 4;
  73.     myBitMap.bounds = srcRect;
  74.     myBitMap.baseAddr = *h + 128;    /* Skip to mask */
  75.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcBic, 0L);
  76.     myBitMap.baseAddr = *h;            /* Now draw icon */
  77.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcOr, 0L);
  78.     HUnlock(h);
  79.     ReleaseResource(h);
  80.  
  81.     ClosePort(&myPort);
  82. out:
  83.     asm {
  84.         MOVE.L (SP)+,A5
  85.     }
  86. }
  87.